#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e5 + 5;

int n, m, k;
int a[N];
string s, t;
int dp[N][45];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> k;
  cin >> s >> t;
  s = ' ' + s;
  t = ' ' + t;
  n = s.size() - 1;
  m = t.size() - 1;
  if (abs(n - m) > k) {
    cout << "No";
    return 0;
  }
  memset(dp, 0x3f, sizeof(dp));
  int padd = k + 1;
  rep(i, 1, k) dp[0][i + padd] = i, dp[i][-i + padd] = i;
  dp[0][padd] = 0;
  rep(i, 1, n) rep(j, max(1, i - k), min(m, i + k)) {
    int d = j - i + padd;
    int& ans = dp[i][d];
    if (s[i] == t[j])
      ans = min(ans, dp[i - 1][d]);
    else {
      // del from s : i - 1 <-> j
      ans = min(ans, dp[i - 1][d + 1] + 1);
      // del from t : i <-> j - 1
      ans = min(ans, dp[i][d - 1] + 1);
      // change s[i] to t[j] : i - 1 <-> j - 1
      ans = min(ans, dp[i - 1][d] + 1);
    }
  }
  // cout << dp[n][m - n + padd] << endl;
  cout << (dp[n][m - n + padd] <= k ? "Yes" : "No");
  return 0;
}